<?php
/*
 * Created on Sep 13, 2010
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
 
include_once("./configure/configure.php");		//--> global var
include_once("./admin/tools/smarty/libs/Smarty.class.php");		//--> out template
include_once("Common.php");
include_once("Strings.php");					//--> String utils
include_once("Session.php");					//-- Session
include_once("./admin/lib/utils/StyleUtils.php");				//--> Style utils

include_once("includeSmarty.php");

$common = new Common();
$objSession			= new Session(DB_TAG_SYSTEM, SESSION_TABLE_NAME);	//-- session

if($objSession->exist()) {
	$customerid = $objSession->getUserID();
}else
	$customerid = 0;

if(isset($_POST['id']))
	$id = $_POST['id'];
else
	$id = $_GET['id'];

if(isset($_POST['content'])){
	$title 		= $_POST['title'];
	$content 	= $_POST['content'];
	$rating 	= $_POST['rating'];
	$yourName 	= $_POST['yourName'];
	$location 	= $_POST['location'];
	
	if(empty($content)){
		$error_message = 'The content is required.';
	}else if(empty($rating)){
		$error_message = 'Please select rating.';
	}else if(empty($yourName)){
		$error_message = 'Your name is required.';
	}else if(empty($title)){
		$error_message = 'Title is required.';
	}
	
	if(empty($error_message)){
		$arrData = array(
			'product_id' 	=> $id,
			'customer_id' 	=> $customerid,
			'title' 		=> strip_tags($title),
			'content' 		=> strip_tags($content),
			'rating' 		=> $rating,
			'userName' 		=> strip_tags($yourName),
			'location' 		=> strip_tags($location)
		);
		
		$common->insertUpdate(DB_TAG_PUBLIC, 'reviews', $arrData);
		
		$error_message = 'Reviews is written, Please click close.';
	}
	
}


$smarty->assign('HOME_URL', HOME_URL);
$smarty->assign('HOME_URL_HTTP', HOME_URL);

$smarty->assign('error_message', $error_message);

$smarty->assign('id', $id);

$smarty->assign('title', $title);
$smarty->assign('content', $content);
$smarty->assign('yourName', $yourName);
$smarty->assign('location', $location);

$smarty->assign('theme', StyleUtils::getTheme());

$smarty->display('login.html');
?>
